package org.cupk2.main;

import org.cupk2.service.event.EventLuceneEmbeddingHandle;
import org.cupk2.service.event.EventLuceneIndexHandle;
import lombok.extern.slf4j.Slf4j;
import org.cupk2.auth.events.EventLogHandle;
import org.cupk2.auth.face.CupkParameter;
import org.cupk2.base.event.face.Cupk2Events;
import org.cupk2.base.event.inter.Cupk2EventHandle;
import org.cupk2.base.web.Cupk2BeanFactory;
import org.cupk2.luser.events.EventLoginHandle;
import org.cupk2.wdap.event.EventWdapHandle;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@MapperScan("org.cupk2")
@ComponentScan(basePackages = {"org.cupk2","com.cupk2"})
@Slf4j
@EnableAsync
public class AppMain {
    public static void main(String[] args) {
        Cupk2BeanFactory.setConfigurableApplicationContext(SpringApplication.run(AppMain.class, args));

        CupkParameter parameter = (CupkParameter) Cupk2BeanFactory.getBean(CupkParameter.class);

        parameter.initXmlToDatabase();

        parameter.initDefaultPaths();

        {

            Cupk2Events.getHandles().add((EventLuceneEmbeddingHandle) Cupk2BeanFactory.getBean(EventLuceneEmbeddingHandle.class));

            Cupk2Events.getHandles().add((EventLuceneIndexHandle) Cupk2BeanFactory.getBean(EventLuceneIndexHandle.class));

            Cupk2Events.getHandles().add((Cupk2EventHandle) Cupk2BeanFactory.getBean(EventLogHandle.class));

            Cupk2Events.getHandles().add((Cupk2EventHandle) Cupk2BeanFactory.getBean(EventLoginHandle.class));

            Cupk2Events.getHandles().add((Cupk2EventHandle) Cupk2BeanFactory.getBean(EventWdapHandle.class));
        }
        System.out.println("-----------------------------------------------------------------------------");
        System.out.println("--------------------------------智绘筑梦，启动！--------------------------------");
        System.out.println("-----------------------------------------------------------------------------");
    }

}
